﻿using NUnit.Framework;
using System.Drawing;

namespace funktionsPlotter.test
{
    [TestFixture]
    class FunktionsPlotter : FunktionsPlotterBase
    {
        [Test]
        public  void Plotten()
        {
            const string p_formel = "x*x";
            const int p_min = 0;
            const int p_max = 5;
            var p_prf = new Point[6];
            p_prf[0].X = 0;
            p_prf[0].Y = 0;
            p_prf[1].X = 1;
            p_prf[1].Y = 1;
            p_prf[2].X = 2;
            p_prf[2].Y = 4;
            p_prf[3].X = 3;
            p_prf[3].Y = 9;
            p_prf[4].X = 4;
            p_prf[4].Y = 16;
            p_prf[5].X = 5;
            p_prf[5].Y = 25;

            var p_erg = Plotten(p_formel, p_min, p_max, 0);

            Assert.AreEqual(p_prf,p_erg);
        }

        [Test]
        public void Compilen()
        {
            const string p_formel = "1+2";

            var p_erg = Compiler.Compilen(p_formel);

            Assert.IsNotNull(p_erg);
        }

        [Test]
        public void x_Werte_generieren()
        {
            const int p_min = -10;
            const int p_max = 10;
            var p_prf = new [] { -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
           
            var p_erg = X_Werte_generieren.x_Werte_generieren(p_min, p_max, 0);

            Assert.AreEqual(p_prf,p_erg);
        }

        [Test]
        public void y_Werte_generieren()
        {
            var p_min_max = new [] {1,2,3};

            var p_erg = Y_Werte_kalkuliern.y_Werte_generieren(x => x * x, p_min_max);
            
            Assert.AreEqual(1,p_erg[0].X);
            Assert.AreEqual(1, p_erg[0].Y);
            Assert.AreEqual(2, p_erg[1].X);
            Assert.AreEqual(4, p_erg[1].Y);
            Assert.AreEqual(3, p_erg[2].X);
            Assert.AreEqual(9, p_erg[2].Y);
        }
    }
}
